package practice1_100;

public class Practice28 {
    //拿needle去整个匹配haystack
    public int strStr(String haystack, String needle) {
        int hayLength=haystack.length();
        int needLength=needle.length();
        for (int i=0;i<hayLength-needLength+1;i++){
            if(haystack.substring(i,i+needLength).equals(needle))
                return i;
            //haystack.substring(i,i+needLength+1);
        }
        return -1;
    }

    public static void main(String[] args) {
        new Practice28().strStr("hello","ll");
    }
}
